home *** CD-ROM | disk | FTP | other *** search
- Path: cleveland.Freenet.Edu!ah739
- From: ah739@cleveland.Freenet.Edu (Leslie J. Somos)
- Newsgroups: comp.lang.c
- Subject: Re: Quotes in C comments
- Date: 20 Mar 1996 07:00:19 GMT
- Organization: Case Western Reserve University, Cleveland, OH (USA)
- Message-ID: <4ioae3$bis@madeline.INS.CWRU.Edu>
- References: <Do6nn5.5rE@oscar.prima.ruhr.de>
- Reply-To: ah739@cleveland.Freenet.Edu (Leslie J. Somos)
- NNTP-Posting-Host: piglet.ins.cwru.edu
-
-
- In a previous article, patrick@oscar.prima.ruhr.de (Patrick Mau) says:
-
- >Hi there,
- >
- >I had a really funny problem with quotes in C programs:
- >
- >The question is:
- > How should a compiler handle the following comments
- >
- >First Example:
- >
- >/*
- > * printf( "/* funny printf */" );
- > * ^^--- Point A
- > */
- >
- >Second Example:
- >
- > /*
- > * You can't do xyz here
- > * ^--- Point B
- > */
- >
- >In the first example the compiler could stop at point A thinking the
- >comment ends at that point. This would be the case if the compiler
- >doesn't check quotes within comments. ( they are usually ignored. )
- >
- >In the second example ( _that_ happened to me with gcc 2.7.2 )
- >the compiler complains about an unterminated character constant
- >at EOF and says it could be at point B.
- >
- >How should a good compiler handle those kinds of comments.
-
- A good compiler should handle it as the C language specification
- says it should. (I don't know offhand.)
-
- But more important immediately to you, is how is it handled by
- the particular compiler that you are required to use.
-
-
- >Should it check for quotes within comments or not ?
- >
- > Best regards ...
- > ... Patrick
- >
-
-
- A suggestion:
-
- printf("%s%s%s", "/", "* a bulletproof printf *", "/");
-
- --
-